<template>
  <div>
    <div class="banner"
         @click="handleBannerClick">
      <img :src="bannerImg"
           alt=""
           class="banner-img">
      <div class="banner-info">
        <div class="banner-title">{{sightName}}</div>
        <div class="banner-number"
             v-if="bannerImgs">
          <span class="iconfont img-icon">&#xe606;</span>
          {{bannerImgs.length}}
        </div>
      </div>
    </div>
    <fade-animation>
      <common-gallery :imgs="bannerImgs"
                      v-show="showGallery"
                      @close="handleGalleryClose"></common-gallery>
    </fade-animation>
  </div>
</template>
<script>
import CommonGallery from 'common/gallery/Gallery'
import FadeAnimation from 'common/fade/FadeAnimation'
export default {
  name: 'DetailBanner',
  components: {
    CommonGallery,
    FadeAnimation
  },
  props: {
    sightName: String,
    bannerImg: String,
    bannerImgs: Array
  },
  data () {
    return {
      showGallery: false
    }
  },
  mounted () {
    console.log(this.sightName, this.bannerImg, this.bannerImgs, 44)
  },
  methods: {
    handleBannerClick () {
      this.showGallery = true
    },
    handleGalleryClose () {
      this.showGallery = false
    }
  }
}
</script>
<style lang="stylus" scoped>
.banner {
  position: relative;
  overflow: hidden;
  height: 0;
  padding-bottom: 55%;

  .banner-img {
    width: 100%;
  }

  .banner-info {
    display: flex;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    color: #ffffff;
    line-height: 0.6rem;
    background: linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.8));

    .banner-title {
      padding: 0 0.2rem;
      flex: 1;
      font-size: 0.32rem;
    }

    .banner-number {
      margin-top: 0.14rem;
      padding: 0 0.32rem;
      height: 0.32rem;
      line-height: 0.32rem;
      border-radius: 0.12rem;
      background: rgba(0, 0, 0, 0.6);
      font-size: 0.24rem;

      .img-icon {
        font-size: 0.24rem;
      }
    }
  }
}
</style>
